<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./js/ajax.primise.js"></script>
</head>

<body>
    <script>

        var arr = []
        // ajax({
        //     type: "get",
        //     url: "http://localhost:3000/user",
        //     data: {},
        // }).then(res => {
        //     console.log(res);
        //     arr.push(res)

        //     ajax({
        //         type: "get",
        //         url: "http://localhost:3000/login",
        //         data: {},
        //     }).then(res => {
        //         console.log(res);
        //         arr.push(res)
        //         ajax({
        //             type: "get",
        //             url: "http://localhost:3000/register",
        //             data: {}

        //         }).then(res=>{
        //             console.log(res);
        //         })
        //     })

        //     console.log(arr);
        // })
        var frist = ajax({
            type: "get",
            url: "http://localhost:3000/register",
            data: {}
        })
        var second = ajax({
            type: "get",
            url: "http://localhost:3000/login",
            data: {}
        })
        var third = ajax({
            type: "get",
            url: "http://localhost:3000/user",
            data: {}
        })

        // console.log(frist);
        // console.log(second);
        // console.log(third);

        // Promise.all 所有请求完成(成功)数据返回一个数据
        //注意:如果有一个不成功，就失败了
        // Promise.all([frist, second, third]).then(res => {
        //     console.log(res);
        // })
        Promise.race([second, frist, third]).then(res => {
            console.log(res);
        })

    </script>
</body>

</html>